begintownscript;

variables;
short creature_count = 0;
short choice = 0;
short pc_counter = 0;
short lead_char = 0;

body;

beginstate 0; //INIT_STATE
	enable_add_chars(1);
	set_crime_tolerance(2);

	set_name(6, "Mayor Anderson");
	set_name(7, "Official");
	set_name(8, "Iracos");
	set_name(9, "Miali");
	set_name(10, "Karl");
	set_name(13, "Samuel");
	set_name(14, "Mitch");
	set_name(15, "Will");
	set_name(16, "Spark");

	//Dialogue Pics
	set_char_dialogue_pic(6,1949,0);
	set_char_dialogue_pic(7,1955,0);
	set_char_dialogue_pic(10,1958,0);
	set_char_dialogue_pic(13,1957,0);
	set_char_dialogue_pic(15,1922,0);
	set_char_dialogue_pic(8,1945,0);
	set_char_dialogue_pic(9,1947,0);
	set_char_dialogue_pic(14,1962,0);

	if(get_flag(0,0) == 0) {
		relocate_character(0,5,12);
		relocate_character(1,6,12);
		relocate_character(2,7,11);
		relocate_character(3,7,10);
		set_flag(0,0,1);
		force_view_center(5,10);
		force_instant_terrain_redraw();
		}


break;


beginstate 1; //EXIT_STATE

	if(town_status(0) == 2) {
		reset_dialog();
		add_dialog_str(0,"As you leave Hektos behind you, you begin to feel a bit of regret. You've clearly been marked as a criminal, which will make completing your quest impossible.",0);
		add_dialog_str(1,"The Empire will send troops once it hears that one of its towns was attacked, so you decide to flee while you still can.",0);
		add_dialog_str(2,"You slip out of the valley, unnoticed and never to return.",0);
		run_dialog(1);
		end_scenario(0);
		}

break;


beginstate 2; //START_STATE
	pc_counter = 0;
	while(char_ok(pc_counter) == 0) {
		pc_counter = pc_counter + 1;
		}
	lead_char = pc_counter;

break;

//Locked trapdoors
beginstate 10; //Inn trapdoor
	block_entry(1);
	message_dialog("This trapdoor is securely locked, and the lock appears to be incredibly complex.","Looks like you can't open it.");
break;


beginstate 12; //Forge trapdoor
	block_entry(1);
	message_dialog("This trapdoor is locked shut with an expertly-crafted lock. Looking at it for a second, you doubt that you could open it.","");
break;

beginstate 15; //leave inn
	if(get_flag(0,13) == 0) {
		message_dialog("Stepping out of the inn, you can't help but notice how peaceful the town of Hektos seems. Nobody seems to be outside, however, which you find a little strange.","");
		set_flag(0,13,1);
	}
break;

beginstate 16; //statue #1
	reset_dialog();
	add_dialog_str(0,"Judging from this figure's robes, you assume that this man was a powerful mage in life. A sign on the statue's base reads:",0);
	add_dialog_str(1,"Incantor Erikson, 789-851. Mage, architect of Pearl Bridge. Killed in freak goatherding accident.",35);
	run_dialog(1);
	set_flag(0,22,1);
break;

beginstate 17; //statue #2
	reset_dialog();
	add_dialog_str(0,"This appears to be a statue of an unassuming Empire official. A sign at the statue's base reads:",0);
	add_dialog_str(1,"Johnathan Wilkinson, mayor of Hektos: 840 - 845. May he rest in peace.",35);
	run_dialog(1);
break;

beginstate 18; //statue #3
	reset_dialog();
	add_dialog_str(0,"This statue accurately captures a very surprised-looking swordsman. A sign at the statue's base reads:",0);
	add_dialog_str(1,"Johenn Ackre, Defender of Yris. Cleared out infestation of Ursagi in 837, killed by basilisk in 841.",35);
	add_dialog_str(2,"Another sign looks like it was added recently:",0);
	add_dialog_str(3,"Please respect Mr. Ackre, and refrain from scrawling graffiti on him.",35);
	run_dialog(1);
break;

beginstate 19; //statue #4, hints at lever
	reset_dialog();
	add_dialog_str(0,"This statue embodies a frazzled-looking Empire official holding an ornate-looking pen. A sign at the bottom of the statue reads:",0);
	add_dialog_str(1,"Phillip Anderson, mayor of Hektos: 845 - ",35);
	if(get_skill_total(18) > 5) {
		add_dialog_str(2,"Looking at the statue a second time, you can't help but notice that the pen in the statue's hand looks strange. It almost looks as if it's a lever of some sort.",0);
		add_dialog_str(3,"You poke at it for a moment, but nothing happens.",0);
		set_flag(0,16,1);
		}
	run_dialog(1);
break;

beginstate 20; //enter city hall
	if(get_flag(0,14) == 0) {
		message_dialog("You enter the city hall of Hektos, and are somewhat impressed by the arched roof of the entry hall. Somebody put a lot of work into this building.","The room is empty right now, except for pillars, chairs, and a relaxed-looking Empire official.");
		set_flag(0,14,1);
		}
break;

beginstate 21; //enter mayor's office
	if(get_flag(0,15) == 0) {
		message_dialog("Opening this door, you're surprised by how dark the room is. You can barely make out the shape of the mayor at a very cluttered-looking desk, which blends in perfectly with the shelves, racks, and piles of paper in the room.","Empire bureaucracy, even at its best, tends to generate slightly more paperwork than this, which suggests that the mayor has been incredibly busy.");
		set_flag(0,15,1);
	}
break;

beginstate 22; //searching paperwork racks
	message_dialog("Searching through the shelves of paper, you find nothing but mind-numbingly boring paperwork. Nothing but trade records, a few legal documents, and some mundane correspondence with other officials.","In short, nothing that would interest an adventurer. Actually, there's probably nothing that would interest an Empire official either.");
break;

beginstate 23; //enter forge/bazaar
	if(get_flag(0,17) == 0) {
		message_dialog("Entering this building, you are immediately hit by a wave of unusually warm air. However, upon looking around the room, you can't tell where it's coming from.","After a confused moment, you notice a series of small vents at the base of the wall, leading you to believe that there's a forge under this building, or something similar.");
		set_flag(0,17,1);
	}
break;

beginstate 24; //docks
	if(get_flag(0,18) == 0) {
		message_dialog("The town of Hektos has a small set of docks, probably just used for fishing. You can't imagine what else people would need them for around here.","You notice that all the boats are on the small side, probably only big enough for two people."); 
		set_flag(0,18,1);
	}
break;

beginstate 25; //try to look at a boat, via specobj script on boats
	reset_dialog();
	add_dialog_str(0,"This small fishing boat is secured to the dock with an insane number of convoluted knots. They look like they'd be almost impossible to untie.",0);
	add_dialog_str(1,"Oh well, it's not your boat, anyway. And it smells like dead fish, too.",0);
	if(party_size() > 2)
		add_dialog_str(2,"Even if you braved the smell, and had somewhere you could take it, your party could never fit in the boat.",0);
	run_dialog(1);
break;

beginstate 26; //storeroom
	if(get_flag(0,19) == 0) {
		message_dialog("The air in this room seems rather stale, as if the brooms lying up against the wall haven't been used in a while. An unimpressive range of gear is strewn about the tables, and most of it looks similarly unused.","");
		set_flag(0,19,1);
	}
break;